package com.admin.core.mapper;

import com.admin.core.entity.SysMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * @author sq-lan
 */
@Mapper
public interface MenuMapper extends BaseMapper<SysMenu> {

    /**
     * 按角色ID和不相等类型列出
     *
     * @param roleIds 角色ID
     * @param type    类型
     * @return {@link List}<{@link SysMenu}>
     */
    List<SysMenu> listByRoleIdsAndNotEqualType(@Param("roleIds") Set<Integer> roleIds, @Param("type") int type);

    @Select("SELECT id id FROM sys_menu WHERE title = #{title}")
    SysMenu findByTitle(@Param("title") String title);

    @Select("SELECT id id FROM sys_menu WHERE name = #{name}")
    SysMenu findByComponentName(@Param("name") String name);

    @Select("update sys_menu set sub_count = #{count} where id = #{id} ")
    void updateSubCntById(@Param("count") int count, @Param("id") int id);
}
